import { ref, getCurrentInstance, nextTick, toRef } from "vue"; 

// 表格拖拽
export function useTableDrag() {
  const proxy = getCurrentInstance()?.proxy
  const tableRef = ref(null);
  nextTick(() => {
    proxy?.dragTable(tableRef);
  })
  return { tableRef, proxy }
}

// 批量表格拖拽
export function useTablesDrag() {
  const proxy = getCurrentInstance()?.proxy
  const tableRefs = ref([]);
  const initTableDrag = () => {
    nextTick(() => {
      tableRefs.value && tableRefs.value.forEach(tableRef => {
        tableRef && proxy?.dragTable(toRef(tableRef));
      })
    })
  }
  return { tableRefs, proxy, initTableDrag }
}